<template>
    <v-table
            :searchFlag="false"
            :pageSize="pageSize"
            :page="page"
            :tableConfig="tableConfig"
            :tableData="tableData"
            :total="total"
            @findData="getTableData"
            @getTableData="getTableData"
            @searhData="setSearhData"
            @selectData="setSelectData"
            @setdialog="setdialog"
            @upData="getTableData"
            ref="table"
    ></v-table>
</template>

<script>
    import table from 'commons/Table'
    import baseMixin from "@/mixins/BaseMixin";

    export default {
        name: "Table",
        mixins: [baseMixin],
        props: {
            data: {
                type: Object
            }
        },
        data() {
            return {
                tableConfig: [
                    {
                        label: this.$t('outbound.userlinenumber'),
                        prop: "adjustmentlinenumber",
                        input: "input",
                    },
                    {
                        label: this.$t('config.sku'),
                        prop: "sku",
                        input: "input",
                    },
                    {
                        label: this.$t('config.loc'),
                        prop: "loc",
                        input: "input",
                    },
                    {
                        label: this.$t('bill.lot'),
                        prop: "lot",
                        input: "input",
                    },
                    {
                        label: this.$t('common.status'),
                        prop: "rtxstatus",
                        input: "select",
                        options: [
                            {code: '0', description: this.$t('code.status17')},
                            {code: '1', description: this.$t('code.status18')}
                        ]
                    },
                  {
                    label: this.$t('ex.adjustmentType'),
                    prop: "adjustmentType",
                    input: "select",
                    options: this.getOptions("querycodeLkup/AdjustmentType")
                  },
                    {
                        label: this.$t('in.lpn'),
                        prop: "id",
                        input: "input",
                    },
                    {
                        label: this.$t('ex.reasoncode'),
                        prop: "reasoncode",
                        input: "input",
                    },
                    {
                        label: this.$t('config.num'),
                        prop: "qty",
                        input: "input",
                    },
                    {
                        label: this.$t('config.packaging'),
                        prop: "packkey",
                        input: "input",
                    },
                    {
                        label: "uom",
                        prop: "uom",
                        input: "input",
                    },
                ],
                tableData: [],
                pageSize: 10,
              page: 1,
                total: 10,
                searhData: {}
            }
        },
        methods: {
            //获取table数据
            async getTableData(page, data) {
                try {
                    let res = await this.$api.post(`/queryAdjustmentdetailList`, {
                        curpage: page,
                        adjustmentkey: this.data.argument.adjustmentkey,
                        adjustmentlinenumber: this.data.argument.adjustmentlinenumber,
                    });
                    
                        this.loading = false;
                        this.tableData = res.page.list;
                      this.page = res.page.curpage;
                        this.pageSize = res.page.pageSize;
                        this.total = res.page.total;
                    
                } catch (e) {
                    this.$message.error(e);
                }
            },
            //搜索值
            setSearhData(data, up) {
                if (!up) {
                    this.searhData = data;
                } else {
                    this.searhData = data;
                    this.getTableData(1, this.searhData);
                }
            },
            //选中的数据
            setSelectData(data) {
                this.$parent.setSelectData(data)
            },
            //进入详情
            async setdialog(data) {
                this.$parent.setdialog(data);
            },
        },
        mounted() {
            this.getTableData(1, {})
        },
        components: {
            'v-table': table
        }
    }
</script>

<style scoped>

</style>